//
//  MineTabeHeadView.m
//  News
//
//  Created by weige on 16/6/13.
//  Copyright © 2016年 weige. All rights reserved.
//

#import "MineTabeHeadView.h"
#import "MineUpImageDownText.h"
@interface MineTabeHeadView()
{
    UIView *orderView;
    UIView *couponview;
    UIView *messageview;
    MineUpImageDownText   *btnorder;
    MineUpImageDownText   *btncoupon;
    MineUpImageDownText   *btnmessage;
}
@end
@implementation MineTabeHeadView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createMineTableViewUI];
    }
    return self;
}

-(void)createMineTableViewUI
{
    orderView=[[UIView alloc]init];
    orderView.backgroundColor=[UIColor whiteColor];
    btnorder=[[MineUpImageDownText alloc]initWithFrame:CGRectZero andTitle:@"我的订单" andImage:@"v2_my_order_icon"];
    [self addSubview:orderView];
    [orderView addSubview:btnorder];
    orderView.tag=0;
    couponview=[[UIView alloc]init];
    couponview.backgroundColor=[UIColor whiteColor];
    btncoupon=[[MineUpImageDownText alloc]initWithFrame:CGRectZero andTitle:@"优惠劵" andImage:@"v2_my_coupon_icon"];
    [self addSubview:couponview];
    [couponview addSubview:btncoupon];
    couponview.tag=1;
    messageview=[[UIView alloc]init];
    messageview.backgroundColor=[UIColor whiteColor];
    btnmessage=[[MineUpImageDownText alloc]initWithFrame:CGRectZero andTitle:@"我的消息" andImage:@"v2_my_message_icon"];
    [self addSubview:messageview];
    [messageview addSubview:btnmessage];
    messageview.tag=2;
    for (int i=0; i<3; i++) {
        UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(click:)];
        UIView *subview= [self viewWithTag:i];
        
        [subview addGestureRecognizer:tap];
    }
}
-(void)click:(UITapGestureRecognizer *)sender
{
    //NSLog(@"%ld",sender.view.tag);
    [[NSNotificationCenter defaultCenter] postNotificationName:@"clickmy" object:nil userInfo:@{@"clicktap":@(sender.view.tag)}];

}
-(void)layoutSubviews
{
    [super layoutSubviews];
   
    orderView.frame=CGRectMake(0, 0, SCREEN_WIDTH/3-1,self.frame.size.height);
   btnorder.frame=CGRectMake(0, 0, orderView.frame.size.width, orderView.frame.size.height);
    couponview.frame=CGRectMake(SCREEN_WIDTH/3, 0, SCREEN_WIDTH/3-1,self.frame.size.height);
    btncoupon.frame=CGRectMake(0, 0, couponview.frame.size.width, couponview.frame.size.height);
    messageview.frame=CGRectMake(SCREEN_WIDTH/3*2, 0, SCREEN_WIDTH/3,self.frame.size.height);
    btnmessage.frame=CGRectMake(0, 0, messageview.frame.size.width, messageview.frame.size.height);
    //NSLog(@"%f",btnView.frame.size.height);
}
@end
